package com.github.nuggets.model.exception;

import com.github.nuggets.model.result.BaseResultInfoInterface;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description:
 * @author: wangsj
 * @date: 2022/3/17 8:14 下午
 */
@Data
@NoArgsConstructor
public class BaseException extends RuntimeException{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected Integer errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public BaseException(BaseResultInfoInterface baseResultInfoInterface) {
        super(baseResultInfoInterface.getResultMsg());
        this.errorCode = baseResultInfoInterface.getResultCode();
        this.errorMsg = baseResultInfoInterface.getResultMsg();
    }

    public BaseException(BaseResultInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.getResultMsg(), cause);
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public BaseException(Integer errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BaseException(Integer errorCode, String errorMsg, Throwable cause) {
        super(errorMsg, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
